package com.opgea.crm.domain.entities;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.opgea.crm.domain.entities.security.CrmUser;


@Entity
@Table(name="taskcomment")
public class TaskComment implements Serializable {

		@Id
		@GeneratedValue
		@Column(name="id")
		private Long id;
		
		@Column(name="comment")
		private String comment;
		
		
		@ManyToOne
		@JoinColumn(name="assignedTo")
		private Employee assignedto;
		
		@ManyToOne
		@JoinColumn(name="task_id")
		private Task task;
		
		@ManyToOne
		@JoinColumn(name="createdBy")
		private CrmUser createdBy;
		
		
		@Temporal(TemporalType.TIMESTAMP)
		@Column(name="createdAt")
		private Date createdAt;

		@JoinColumn(name="status")
		@ManyToOne
		private SetupsValue status;
		
		
		public Long getId() {
			return id;
		}

		public void setId(Long id) {
			this.id = id;
		}

		public String getComment() {
			return comment;
		}

		public void setComment(String comment) {
			this.comment = comment;
		}

		public Employee getAssignedto() {
			return assignedto;
		}

		public void setAssignedto(Employee assignedto) {
			this.assignedto = assignedto;
		}

		public Task getTask() {
			return task;
		}

		public void setTask(Task task) {
			this.task = task;
		}

		public CrmUser getCreatedBy() {
			return createdBy;
		}

		public void setCreatedBy(CrmUser createdBy) {
			this.createdBy = createdBy;
		}

		public Date getCreatedAt() {
			return createdAt;
		}

		public void setCreatedAt(Date createdAt) {
			this.createdAt = createdAt;
		}
		
		

		public SetupsValue getStatus() {
			return status;
		}

		public void setStatus(SetupsValue status) {
			this.status = status;
		}

		public TaskComment() {
			super();
			// TODO Auto-generated constructor stub
		}

		public TaskComment(Long id, String comment, Employee assignedTo,SetupsValue status, Task task, CrmUser createdBy, Date createdAt) {
			super();
			this.id = id;
			this.comment = comment;
			this.assignedto  = assignedTo;
			this.task = task;
			this.createdBy = createdBy;
			this.createdAt = createdAt;
			this.status = status;
		}

		




		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + ((id == null) ? 0 : id.hashCode());
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			TaskComment other = (TaskComment) obj;
			if (id == null) {
				if (other.id != null)
					return false;
			} else if (!id.equals(other.id))
				return false;
			return true;
		}

		@Override
		public String toString() {
			return "IssueComment [id=" + id + ", comment=" + comment + ", assignedTo=" + assignedto + ", task=" + task
					+ ", createdBy=" + createdBy + ", createdAt=" + createdAt + ",status=" + status +"]";
		}

}
